﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using System.Text;

namespace TCCVoigt.Controllers
{
    public class testeController : Controller
    {
        //
        // GET: /teste/

        public ActionResult Index()
        {
            return View();
        }

        public JsonResult getAlocacao()
        {
            List<Alocacao> lstAlocacao = new List<Alocacao>();
            List<Solicitacoes> lstSolicitacoes1 = new List<Solicitacoes>();
            lstSolicitacoes1.Add(new Solicitacoes("/Date(1332835200000)/", "/Date(1332957600000)/", "<b>SMS 623384</b>2<br><b>", "ganttRed", "SMS 623384"));
            lstAlocacao.Add(new Alocacao("Diego Lima", "", lstSolicitacoes1));

            List<Solicitacoes> lstSolicitacoes2 = new List<Solicitacoes>();
            lstSolicitacoes2.Add(new Solicitacoes("/Date(" + ConvertToTimestamp(new DateTime(2012, 3, 31, 8, 55, 0)) + ")/", "/Date(" + ConvertToTimestamp(new DateTime(2012, 4, 05, 18, 0, 0)) + ")/", "<b>SMS 623384</b>2<br><b>", "ganttGreen", "SMS 623384"));
            lstSolicitacoes2.Add(new Solicitacoes("/Date(" + ConvertToTimestamp(new DateTime(2012, 4, 9, 8, 0, 0)) + ")/", "/Date(" + ConvertToTimestamp(new DateTime(2012, 4, 10, 12, 0, 0)) + ")/", "<b>SMS 623384</b>", "ganttOrange", "SMS 623384"));
            lstSolicitacoes2.Add(new Solicitacoes("/Date(" + ConvertToTimestamp(new DateTime(2012, 4, 9, 13, 30, 0)) + ")/", "/Date(" + ConvertToTimestamp(new DateTime(2012, 4, 10, 15, 0, 0)) + ")/", "<b>Reuniao</b>", "ganttRed", "Reunião"));
            lstSolicitacoes2.Add(new Solicitacoes("/Date(" + ConvertToTimestamp(new DateTime(2012, 4, 9, 15, 0, 0)) + ")/", "/Date(" + ConvertToTimestamp(new DateTime(2012, 4, 10, 18, 0, 0)) + ")/", "<b>SMS 623384</b>", "ganttOrange", "SMS 623384"));
            lstAlocacao.Add(new Alocacao("Gilberto Rocha", "", lstSolicitacoes2));

            JsonResult result = new JsonResult();
            result.Data = lstAlocacao;
            result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return result;
        }

        private string ConvertToTimestamp(DateTime value)
        {
            TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());
            return span.TotalSeconds+"000";
        }
    }

    public class Alocacao
    {
        public string name { get; set; }
        public string desc { get; set; }
        public List<Solicitacoes> values { get; set;}

        public Alocacao(string name, string desc, List<Solicitacoes> values)
        {
            this.name = name;
            this.desc = desc;
            this.values = values;
        }
    }

    public class Solicitacoes
    {
        public string from {get; set;}
        public string to {get; set;}
        public string desc {get; set;}
        public string customClass {get; set;}
        public string label { get; set; }

        public Solicitacoes(string from, string to, string desc, string customClass, string label)
        {
            this.from = from;
            this.to = to;
            this.desc = desc;
            this.customClass = customClass;
            this.label = label;
        }
    }

}
